<?php

class Mageex_Robot_Block_Adminhtml_Robot_Edit_Tab_Templates extends Mage_Adminhtml_Block_Widget_Form
{
	  protected function _prepareForm()
	  {
			if ($head = $this->getLayout()->getBlock('head')) {
				$head->setCanLoadCalendarJs(true);
			}
		  $form = new Varien_Data_Form();
		  
		  $fieldset = $form->addFieldset('robot_form', array('legend'=>Mage::helper('robot')->__('Templates')));
			
			
			$guide = "This is the template field for the title of posts.<br/><br/>- Template tags in curly braces, i.e. {amazontitle}, will be replaced with the title returned by the respective module. See the list to the right for all available template tags.<br/><br/>- You can use template tags several times but beware that Wordpress has a length limit of 255 characters on titles. Longer titles will get cut.<br/><br/>- You can also enter any other text you want to display in your titles.<br/>";
			$afterElementHtml = '<p class="note">' . $guide . '<strong>Title Template Tags</strong><br/>{title}<br/>{amazontitle}<br/>{articletitle}<br/>{ebaytitle}<br/>{rsstitle}<br/>{keyword}</p>';
			$fieldset->addField('title_template', 'textarea', array(
			  'label'     => Mage::helper('robot')->__('Template title'),
			  'class'     => 'required-entry',
			  'required'  => true,
			  'name'      => 'title_template',
			  'after_element_html' => $afterElementHtml,
		  ));
		  
		  $guide = 'This is the template field for the body of posts.<br/><br/>- Template tags in curly braces, i.e. {amazon}, will be replaced with the content returned by the respective module. See the list to the right for all available template tags.<br/><br/>- You can use template tags several times to add more items to the posts, i.e. 2 Amazon products.<br/><br/>- You can also enter any other text or HTML code you want to display in your posts.<br/>';
		  $afterElementHtml = '<p class="note">' . $guide . '<strong>Content Template Tags</strong><br/>{amazon}<br/>{article}<br/>{ebay}<br/>{rss}<br/>{keyword}<br/>{amazonlist}</p>';
			$fieldset->addField('content_template', 'textarea', array(
			  'label'     => Mage::helper('robot')->__('Template content'),
			  'class'     => 'required-entry',
			  'required'  => true,
			  'name'      => 'content_template',
			  'after_element_html' => $afterElementHtml,
		  ));
		  if ( Mage::getSingleton('adminhtml/session')->getRobotData() )
		  {
			  $form->setValues(Mage::getSingleton('adminhtml/session')->getRobotData());
			  Mage::getSingleton('adminhtml/session')->setRobotData(null);
		  } elseif ( Mage::registry('robot_data') ) {
			  $form->setValues(Mage::registry('robot_data')->getData());
		  }
		  
		  
		  $this->setForm($form);
		  return parent::_prepareForm();
	  }
}